<template>
  <div>
    <i class="el-icon-arrow-left m-b-20" @click="back"></i>
    <el-descriptions
      :title="'账单号：' + detail.billCode"
      :extra="detail.billDate"
      :column="7"
      :colon="false"
      direction="vertical"
      border
    >
      <el-descriptions-item
        label="名称"
        label-class-name="my-label"
        content-class-name="my-content"
        >待询问</el-descriptions-item
      >
      <el-descriptions-item
        label="联系人"
        label-class-name="my-label"
        content-class-name="my-content"
        >待询问</el-descriptions-item
      >
      <el-descriptions-item
        label="账单金额（元）"
        label-class-name="my-label"
        content-class-name="my-content"
        >{{ detail.billMoney }}</el-descriptions-item
      >
      <el-descriptions-item
        label="状态"
        label-class-name="my-label"
        content-class-name="my-content"
      >
        <span v-if="detail.payStatus == 1">未付款</span>
        <span v-if="detail.payStatus == 2">已付款</span>
        <span v-if="detail.payStatus == 3">付款失败</span>
        <span v-if="detail.payStatus == 4">付款中</span>
      </el-descriptions-item>
      <el-descriptions-item
        label="支付方式"
        label-class-name="my-label"
        content-class-name="my-content"
      >
        <span v-if="detail.payType == 0">线上</span>
        <span v-if="detail.payType == 1">线下</span>
      </el-descriptions-item>
      <el-descriptions-item
        label="支付时间"
        label-class-name="my-label"
        content-class-name="my-content"
        >{{ detail.payTime }}</el-descriptions-item
      >
      <el-descriptions-item
        label="备注"
        label-class-name="my-label"
        content-class-name="my-content"
        >{{ detail.remark }}</el-descriptions-item
      >
    </el-descriptions>
    <div class="m-t-20"></div>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page="page"
      ref="crud"
      v-model="form"
      @current-change="currentChange"
      @size-change="sizeChange"
      @on-load="onLoad"
    >
    </avue-crud>
  </div>
</template>

<script>
import { getPage } from "@/api/business/filling-record-user";
import { mapGetters } from "vuex";

export default {
  data() {
    return {
      form: {},
      box: false,
      props: {
        label: "title",
        value: "key",
      },
      menuGrantList: [],
      dataScopeGrantList: [],
      menuTreeObj: [],
      dataScopeTreeObj: [],
      selectionList: [],
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        border: true,
        index: true,
        selection: false,
        viewBtn: true,
        menu: false,
        header: false,
        column: [
          { label: "加注单号" },
          { label: "加注量（kg）" },
          { label: "加注金额（元）" },
          { label: "收益（元）" },
          { label: "加注时间" },
        ],
      },
      data: [],
    };
  },
  computed: {
    ...mapGetters(["permission"]),
  },
  props: {
    detail: {
      type: Object,
    },
  },
  methods: {
    back() {
      this.$emit("back");
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getPage(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
      });
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.crud.toggleSelection();
        });
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
  },
};
</script>

<style lang="scss">
.el-descriptions__header {
  background: #f8fafd;
  border: 1px solid #eee;
  line-height: 40px;
  padding: 0 10px;
  margin: 0;
}
.my-label {
  font-weight: bold !important;
  background: #fff !important;
  color: #000 !important;
  border-bottom: 1px solid #eee;
  border-top: 0px solid #eee;
}
</style>
